import request from '@/utils/request'
import * as qs from 'qs'

export function getList(query) {
  return request.get('/api/sys/job?' + qs.stringify(query))
    .then(json => {
      if (json.result) {
        return json.data
      } else {
        throw new Error(json.message)
      }
    })
}

export function count(query) {
  return request.get('/api/sys/job/count?' + qs.stringify(query))
    .then(json => {
      if (json.result) {
        return json.data
      } else {
        throw new Error(json.message)
      }
    })
}

export function recommend(jobId) {
  return request.post(`/api/sys/job/recommend/${jobId}`)
    .then(json => {
      if (json.result) {
        return json.data
      } else {
        throw new Error(json.message)
      }
    })
}

export function cancelRecomment(jobId) {
  return request.post(`/api/sys/job/cancelRecomment/${jobId}`)
    .then(json => {
      if (json.result) {
        return json.data
      } else {
        throw new Error(json.message)
      }
    })
}
